package de.dhbw.karlsruhe.picsim.gui.renderer;

import de.dhbw.karlsruhe.picsim.model.memory.RegisterValue;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: user
 * Date: May 6, 2010
 * Time: 1:04:43 AM
 */
public final class HexRenderer extends DefaultTableCellRenderer {
    @Override
    public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected,
                                                   final boolean hasFocus,
                                                   final int row, final int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        if (value instanceof RegisterValue) {
            final int i = ((RegisterValue) value).asInteger();
            setText(Integer.toHexString(i));
        }
        return this;
    }
}
